from core.item import Item
from core.action import Action
from core.support import get_game, set_cutscene

class Flint(Item):
    def __init__(self):
        Item.__init__(self, "flint")    # do basic initialization for every item
        
        # build list of actions
        self.add_action(Use)
        
    def get_description(self):
        return "flint"

# define actions for this item
class Use(Action):
    def __init__(self):
        Action.__init__(self, "use_flint")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        game = get_game()
        player = game.get_player()
        if player.inventory.has_key('wood'):
            return "Use flint with wood"
        else:
            return "Use flint"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"

    def do_action(self,game,room,request):
        player = game.get_player()
        if room.get_id() == 'startingpoint':
            if player.inventory.has_key('wood'):
                set_cutscene("You create a signal fire!")
                room.signal_fire_created = True
                player.pop_item('wood')
            else:
                set_cutscene("Nothing to use the flint with here.")
        elif player.inventory.has_key('wood'):
            set_cutscene("Not a good place to start a fire...")
        else:
            set_cutscene("Nothing to use the flint with here.")
        return